//
//  KDSettingViewController.m
//  LaiKeDaoClient
//
//  Created by dongkedi的iMac on 15/11/9.
//  Copyright © 2015年 LKD. All rights reserved.
//

#import "KDSettingViewController.h"
#import "KDServiceViewController.h"
#import "KDBlackListViewController.h"

@interface KDSettingViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    UITableView     *_tableView;
}


@end

@implementation KDSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [self setNaviLeftButton];
    [self setNaviTitle:@"设置"];
    
    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _tableView.dataSource = self;
    _tableView.delegate   = self;
    _tableView.backgroundColor = [UIColor colorWithHexString:@"0xF2F2F2"];
    [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.view addSubview:_tableView];
}

- (void)viewWillAppear:(BOOL)animated
{
    SharedAppDelegate.tabBarController.tabBarIsHiden = YES;
}

- (void)viewWillDisappear:(BOOL)animated
{
    SharedAppDelegate.tabBarController.tabBarIsHiden = NO;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 2;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
{
    return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 58;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        [self.navigationController pushViewController:[[KDServiceViewController alloc] init] animated:YES];
    }else{
        [self.navigationController pushViewController:[[KDBlackListViewController alloc] init] animated:YES];
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *CustomCellIdentifier = [NSString stringWithFormat:@"CellIdentifier%ld",(long)indexPath.row+indexPath.section*10];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];
    if (cell ==nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CustomCellIdentifier];
        UIImageView *nextMonthImageView = [[UIImageView alloc] initWithFrame:(CGRect){kScreenWidth-30,23,13/2,21/2}];
        [nextMonthImageView setImage:[UIImage imageNamed:@"btn_next2@2x.png"]];
        [cell.contentView addSubview:nextMonthImageView];
        UIView  *line = [[UIView alloc] initWithFrame:(CGRect){0,57,WIDTH(cell.contentView),1}];
        [line setBackgroundColor:[UIColor colorWithHexString:@"0xF2F2F2"]];
        [cell.contentView addSubview:line];
    }
    if (indexPath.row == 0) {
        [cell.textLabel setText:@"  我的服务"];
    }else{
        [cell.textLabel setText:@"  黑名单"];
    }
    [cell.textLabel setTextColor:[UIColor colorWithHexString:@"666666"]];
    [cell.textLabel setFont:[UIFont systemFontOfSize:15]];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
